package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CategoryMapper {
    //根据id查询分类信息
    @Select("select * from category where id=#{id}")
    Category findById(Long id);
    //根据name查询分类信息
    @Select("select * from category where name = #{name}")
    Category findByName(String name);

    //添加套餐分类查询
    @Insert("insert into category values (null,#{type},#{name},#{sort}," +
            "#{createTime},#{updateTime},#{createUser},#{updateUser})")
    Integer save(Category category);
    //分页查询
    @Select("select * from category order by sort asc")
    List<Category> findAll();
    //修改菜品
    Integer update(Category category);
    //删除菜系或者套餐名
    @Delete("delete from category where id = #{id}")
    Integer delete(Long id);
    //根据类型查询类别表数据
    List<Category> findAllByPage(@Param("type") Integer type);
}
